package com.xiaoxi.exam.job;


import com.xiaoxi.exam.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Slf4j
public class RefundJob {

    @Autowired
    private OrderService orderService;

    @Scheduled(cron = "0 0 1 * * ? ")
    public void startRefund() {
        log.info("refund job start : {}", LocalDateTime.now());
        long start = System.currentTimeMillis();
        orderService.expireRefund();
        long end = System.currentTimeMillis();
        log.info("refund job end , take {}ms", end - start);
    }
}
